<#include "/admin/public.html">
<div style="padding:5px;">
	<table class="layui-table" lay-skin="line" id="example-basic">
	  <thead>
		<tr>
		  <th>链接名称</th>
		  <th>链接地址</th>
		  <th style="white-space:nowrap;" nowrap="nowrap">操作</th>
		</tr> 
	  </thead>
	  <tbody>
		<#if linkList?? && linkList??>
		<#list linkList.content as configList>
		<tr id="${configList.id!''}">
		  <td class="add">${configList.linkname!''}</td>
		  <td class="add">${configList.linkurl!''}</td>
		  <td style="white-space:nowrap;" nowrap="nowrap">		
	  		 <a href="/admin/configuration/updateLink.html?id=${configList.id!''}" data-toggle="ajax" data-href-index="/admin/configuration/index" data-width="80%" data-height="95%" data-title="${configList.title!''}">
	  			<i class="layui-icon">&#xe642;</i>
	  			修改
	  		 </a>
	  		 <a href="#" style="margin-left:10px;" data-toggle="tip" data-title="请确认是否删除记录？" onclick="deleteLink('${configList.id!''}');">
	  			<i class="layui-icon" style="color:red;">&#x1006;</i>
	  			删除
	  		 </a>
	      </td>
		</tr>
		</#list>
		</#if>
	  </tbody>
	</table>
</div>
<div style="padding:5px;">
	<div class="col-lg-12" id="page" style="text-align:center;"></div>
</div>
<script>
layui.use(['laypage', 'layer','form','laydate'], function(){
  var laypage = layui.laypage
  ,layer = layui.layer;
  laypage({
		cont: 'page'
		,pages: <#if linkList??>${linkList.totalPages}<#else>0</#if> //总页数
		,curr:<#if linkList??>${linkList.number+1}<#else>0</#if>
		,groups: 5 //连续显示分页数
		,jump:function(data , first){
			if(!first){
				location.href = "/admin/configuration/editLink.html?p="+data.curr ;
			}
		}
   });
});

function deleteLink(id){
	layer.open({
		  icon: 2, 
		  title:'提示',
		  skin: 'layui-layer-demo', //样式类名
		  closeBtn: 1, //不显示关闭按钮
		  shadeClose: true, //开启遮罩关闭
		  content: '请确认是否删除记录？',
		  btn: ['确定', '取消'],
		  yes: function(){
			  $.ajax({
					type: "POST",
					url: "/admin/configuration/deleteLink.html" ,
					dataType: "text",
					data: {id:id},
					async: false,
					beforeSend:function(){
						
					},
					success: function(data) {
						$("#"+id).remove();
						layer.closeAll();
					}
					
				});
	      }
		});
}
</script>